package com.pug.zixun.controller.user;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pug.zixun.bo.UserBo;
import com.pug.zixun.controller.BaseController;
import com.pug.zixun.pojo.User;
import com.pug.zixun.service.user.IUserService;
import com.pug.zixun.vo.UserVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.pug.generator.anno.PugDoc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 谢迅
 * @version 1.0
 * @date 2022/9/7 13:06
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@PugDoc(name="用户",tabname="kss_user")
public class UserController extends BaseController {
    private final IUserService iUserService;
    @PostMapping("/user/getById/{userid}")
    public UserBo getById(@PathVariable("userid") Long userid){
        UserBo user = iUserService.getUserById(userid);
        user.setPassword("");
        return user;
    }
    @PostMapping("/user/load")
    public IPage<UserBo> load(@RequestBody UserVo userVo){
        IPage<UserBo> userBoIPage = iUserService.pageUser(userVo);
        return userBoIPage;
    }
    @PostMapping("/user/saveOrUpdateUser")
    public UserBo saveOrUpdateUser(@RequestBody User user){
        return iUserService.saveOrUpdateUser(user);
    }
}
